<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <style type="text/css">
        #form2{
            text-align: center;
        }
        #img2{
            width: 400px;
            height: 400px;
        }
    </style>
</head>
<body>
<form action="imgload.php" method="post" id="form2" enctype="multipart/form-data">
    <h2>用户中心</h2>
    <?php
        $oldName = $_FILES['file']['name'];
        $arr = explode('.',$oldName);
        print_r($arr);
        $newName = md5($oldName.time()).'.'.$arr[count($arr)-1];
        move_uploaded_file($_FILES['file']['tmp_name'],'img/'.$newName);
        $img_url = 'img/'.$newName;
    ?>
    <img id="img2" src="<?php echo $img_url; ?>" ><br/><br/>
    <input type="submit" name="" id="" value="更换头像" />
</form>
</body>
</html>
